/**
 * Copyright (C), 2015-2020, 云帐房
 * FileName: HttpRemoveDataSource
 * Author:   cjz
 * Date:     2020/5/14 上午11:02
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.yzf.wisecoder.remotedata;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.yzf.cframework.common.http.HttpUtils;
import com.yzf.cframework.common.json.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : HttpRemoveDataSource
 * @Description : http 接口获取远端数据
 * @Author : cjz
 * @Date: 2020-05-14 11:02
 */
@Slf4j
public class HttpRemoteDataSource extends AbstractRemoteDataSource {

    public HttpRemoteDataSource(RemoteInfo remoteInfo) {
        super(remoteInfo);
    }

    @Override
    public HttpRemoteDataSource execute() {
        String url = remoteInfo.getUrl()+remoteInfo.getExecute();
        result = HttpUtils.get(url, null);
        return this;
    }

    @Override
    public List<Map> result() {
        return JsonUtils.toList(result.toString(), Map.class);
    }

}
